package demo2;
class Money implements Cloneable{
    public double money = 99.99;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class People implements Cloneable{
    public int age;
    public String name;
    Money money = new Money();//组合

    public People(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        //return super.clone();
        People temp = (People) super.clone();
        temp.money = (Money) this.money.clone();
        return temp;
    }
}
